package algo;

import java.util.ArrayList;

public class Player 
{String name;
 ArrayList <RPSEnum> enu;
 int result;
 
 static int taille;
 int valuetableau=0;
 int score;
 

 
 /** Premier constructeur de player
  * **/
	 Player (String name, ArrayList <RPSEnum> maliste)
		 {this.name=name;
		 this.enu=maliste;
		 result=0;//0perdre 1 tie 2 gagné
		 taille=10;
		 score=0;
			 
		 }
	 /**Deuxieme constructeur de player 
	  * */
	 Player (String name)
		 {
		 this.name=name;
		 taille=10;
		 this.enu= this.RandomMove(10); 
		 result=0;
		
			 score=0;
		 }
	 /*Fonction qui génére un arraylist de mouvement
	  * **/
	 ArrayList <RPSEnum> RandomMove(int size)
	 {
	 int i;
	 int temp;
	 RPSEnum elementcourant=RPSEnum.ROCK;
	 ArrayList <RPSEnum> enu2=new ArrayList <RPSEnum>();
		 for (i=0; i<=10; i++)
		 {
			temp  = (int) (Math.random() * 4 );
			System.out.println(" "+elementcourant );
			System.out.println(" "+temp );
			if (temp==1)
			{
				elementcourant=RPSEnum.ROCK;
			}
			else if (temp==2)
			{
				elementcourant=RPSEnum.PAPER;
			}
			else if (temp==3)
			{
				elementcourant=RPSEnum.SCISSOR;
			}
			
			enu2.add(elementcourant);
		 }
		 return enu2;
	 }
	 
	 RPSEnum getNextMove(ArrayList <RPSEnum> array, int index) 
	 {
	 /*RPSEnum element=enu.get(valuetableau);
	
	  valuetableau++;*/
		 RPSEnum element=array.get(index++);
		 
	 return element;
	}
	 
	 String getName()
	 {return name;}
	 
	 int getTaille()
	 {return taille;}
	 
	 void setResult(int result)
	 {
		 this.result=result;
	 }
	 
	int getResult()
	 {return result;}
	 
	 ArrayList <RPSEnum> getListdecoups()
	 {return enu;}
	 
	void setListdecoups( ArrayList <RPSEnum> laliste)
	 {
		this.enu=laliste;
	 }
	
	public int getScore()
	{return score;
	}
	
	public void setScore(int score)
	{
		this.score=score;
	}
	 
	 public void clearPlayer()
	 {name=null;
	 enu.clear();
	  result=0;
	 taille=0;
	 valuetableau=0;
	 	} 
	 
	/* 

 and a RPSEnum getNextMove() method which returns the next element 
from the player's collection of moves. (Do not provide a getter for the collection of moves, 
this is poor encapsulation.)

Now add a new method Result play(Player p1, Player p2) to class RockPaperScissors. 
In that method, just return LOST, for now. 
**/

}
